package com.mallcai.bigdata.ladon.dpl.mapper.dashboard;

import com.mallcai.bigdata.ladon.dpl.entity.dashboard.SqlRunLogStatic;
import com.mallcai.bigdata.ladon.dpl.mapper.dashboard.provider.SqlRunLogStaticSqlProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author gst
 * @date 2019-12-30 20:36
 */
@Repository
public interface SqlRunLogStaticMapper {
    @InsertProvider(type = SqlRunLogStaticSqlProvider.class, method = "insert")
    int insert(SqlRunLogStatic sqlRunLog);

    @SelectProvider(type = SqlRunLogStaticSqlProvider.class, method = "getByParams")
    List<SqlRunLogStatic> getByParams(@Param("params") Map<String, Object> params);

    @SelectProvider(type = SqlRunLogStaticSqlProvider.class, method = "getTopCount")
    List<SqlRunLogStatic> getTopCount(@Param("params") Map<String, Object> params);

    @SelectProvider(type = SqlRunLogStaticSqlProvider.class, method = "getTopAvgTime")
    List<SqlRunLogStatic> getTopAvgTime(@Param("params") Map<String, Object> params);

    @SelectProvider(type = SqlRunLogStaticSqlProvider.class, method = "getAllReportCountDataByDate")
    List<SqlRunLogStatic> getAllReportCountDataByDate(@Param("params") Map<String, Object> params);

    @SelectProvider(type = SqlRunLogStaticSqlProvider.class, method = "getAllReportAvgTimeDataByDate")
    List<SqlRunLogStatic> getAllReportAvgTimeDataByDate(@Param("params") Map<String, Object> params);

    @InsertProvider(type = SqlRunLogStaticSqlProvider.class, method = "mergeInsert")
    int mergeInsert(@Param("params") Map<String, Object> params);

    /**
     * 获取历史总的访问次数
     *
     * @return int
     */
    @Select({
            "select sum(total_count) from " + SqlRunLogStaticSqlProvider.TB_SQL_RUN_LOG_STATIC
    })
    int getVisitSize();
}
